#pragma once

#ifndef _CORE_LOGIN_HELPER_H_
#define _CORE_LOGIN_HELPER_H_

#include "Poco\Types.h"

#include <map>

namespace ExamSystem
{
    /**************************************************************************\
     Component:     CLoginHelper
     Description:
        This class provides interface for user login
    \**************************************************************************/
    class CLoginHelper
    {
    public:
        CLoginHelper(void);
        ~CLoginHelper(void);

    public:
        // set properties, available options are:
        //  host            : MySql server's address
        //  port           : MySql server's port
        //  username        : user
        //  password        : password for the user
        //  database        : the name of target database
        //  studentTable    : the name of the table hold the students' information
        //  stuName         : the name of the column that contains the student's name
        //  stuNumber       : the name of the column that contains the student's number
        //  invigilatorTable: the name of the table hold the invigilators' user names and passwords
        //  invUsername     : the name of the column that contains the invigilators' user names
        //  invPassword     : the name of the column that contains the invigilators' passwords
        void SetProperty(const std::string &property, const std::string &value);

        // the student login, check name and number
        enum OperationResult { Error, Succeeded, Failed };      
        OperationResult StudentLogin(const std::string &name, const std::string &number);

        // the invigilator login, check name and password
        OperationResult InvigilatorLogin(const std::string &user, const std::string &password);

    protected:
        void GenerateConnectionString(void);

    protected:
        std::map<std::string, std::string> m_options;
        std::string m_connectionString;
    };
}

#endif